<?php
/********************************************************
** Copyright 2010-2013. Todos los derechos reservados. **
** Desarrollado y Gestionado por:					   **
** Sugey Quintero (Analista)						   **
** José G. De Freitas (Programador)					   **
** Klaudia Uribe (Diseñadora Web)					   **
** Cesar Isturiz (Diseñador Web)					   **
**				S E A  v1.0							   **
*********************************************************/
session_start();
include("conexion.php");

	if (isset($_SESSION['name']) and isset($_SESSION['tiempo'])) {
        include("Tiempo.php");
	date_default_timezone_set('America/Caracas'); setlocale(LC_TIME, 'spanish');
	$usuario = $_SESSION['name'];
	$fecha = date("Y-m-d H:i:s");
	$auditoria = mysql_query("INSERT INTO auditoria SELECT '$usuario', '$fecha' , 'Visualizar estadisticas del personal' ");

    }else {
		echo "<script>alert('Debe ingresar al sistema primero');</script>";
		echo "<script>document.location.href='index.php';</script>";
	}

//estadisticas
include "libchart/classes/libchart.php";
//Personal en general
	$chart = new PieChart();
	$dataSet = new XYDataSet();
//Docentes
	$chart1 = new PieChart();
	$dataSet1 = new XYDataSet();
//Obreros
	$chart2 = new PieChart();
	$dataSet2 = new XYDataSet();
//Administrativos
	$chart3 = new PieChart();
	$dataSet3 = new XYDataSet();

$sql=mysql_query("SELECT Cargo, COUNT(*) FROM personal GROUP BY Cargo");
$sql1=mysql_query("SELECT Grado, COUNT(*) FROM docente WHERE Status = 'Actual' GROUP BY Grado");
$sql2=mysql_query("SELECT Cargo, COUNT(*) FROM obrero GROUP BY Cargo");
$sql3=mysql_query("SELECT Cargo, COUNT(*) FROM administrativo GROUP BY Cargo");

//Personal en General
while ($row=mysql_fetch_array ($sql)){
	$dataSet->addPoint(new Point("$row[0]: $row[1]",$row[1]));
}
	$chart->setDataSet($dataSet);
	$chart->setTitle("Cantidad de personal en la institucion");
	$chart->render("graficos/ListadoTotal.png");

//Docentes
while ($row1=mysql_fetch_array ($sql1)){
	if ($row1[0]==''){ $row='Sin asignar'; } else { $row=$row1[0]; }
	$dataSet1->addPoint(new Point("$row grado: $row1[1]",$row1[1]));
}
	$chart1->setDataSet($dataSet1);
	$chart1->setTitle("Cantidad de Docentes en la institucion");
	$chart1->render("graficos/ListadoDocentes.png");

//Obreros
while ($row2=mysql_fetch_array ($sql2)){
	$dataSet2->addPoint(new Point("$row2[0]: $row2[1]",$row2[1]));
}
	$chart2->setDataSet($dataSet2);
	$chart2->setTitle("Cantidad de Obreros en la institucion");
	$chart2->render("graficos/ListadoObreros.png");

//Administrativos
while ($row3=mysql_fetch_array ($sql3)){
	$dataSet3->addPoint(new Point("$row3[0]: $row3[1]",$row3[1]));
}
	$chart3->setDataSet($dataSet3);
	$chart3->setTitle("Cantidad de Administrativos en la institucion");
	$chart3->render("graficos/ListadoAdministrativos.png");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Estadisticas del Personal</title>
<link rel="shortcut icon" type="image/x-icon" href="../favicon.ico">
<link href="style.css" rel="stylesheet" type="text/css" />
<script language="javascript" src="js/funciones.js"></script>
<!-- calendario-->
<link rel="stylesheet" type="text/css" href="src/css/jscal2.css">
<link rel="stylesheet" type="text/css" href="src/css/border-radius.css">
<link rel="stylesheet" type="text/css" href="src/css/steel/steel.css">
<script type="text/javascript" src="src/js/jscal2.js"></script>
<script type="text/javascript" src="src/js/lang/es.js"></script>
<!-- fin calendario-->
<!-- botones-->
<link type="text/css" href="js/css/smoothness/jquery-ui-1.8.16.custom.css" rel="Stylesheet" />      
<script type="text/javascript" src="js/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.16.custom.min.js"></script> 
<script>
var j$ = jQuery.noConflict();
j$(document).ready(function(){
j$(".button").button();
});

j$(function(){
	j$('#menu li a').click(function(event){
		var elem = j$(this).next();
		if(elem.is('ul')){
			event.preventDefault();
			j$('#menu ul:visible').not(elem).slideUp();
			elem.slideToggle();
		}
	});
});
</script>
<script>
function cargo(car){ 
	if(car=="Docente"){
		document.getElementById('docente').style.display="inline";
		document.getElementById('general').style.display="none";
		document.getElementById('obrero').style.display="none";
		document.getElementById('administrativo').style.display="none";
	}else if(car=="Obrero"){
		document.getElementById('obrero').style.display="inline";
		document.getElementById('administrativo').style.display="none";
		document.getElementById('docente').style.display="none";
		document.getElementById('general').style.display="none";
	}else if(car=="Administrativo"){
		document.getElementById('administrativo').style.display="inline";
		document.getElementById('obrero').style.display="none";
		document.getElementById('docente').style.display="none";
		document.getElementById('general').style.display="none";
	}else if(car==""){
		document.getElementById('general').style.display="inline";
		document.getElementById('docente').style.display="none";
		document.getElementById('administrativo').style.display="none";
		document.getElementById('obrero').style.display="none";
	}
}
</script>
</head>

<body>
<div id="wrap">
<div id="header">
<div id="hora">
<?php include("Hora.php"); ?>
</div>
<div id="topnav">
	<?php include("MenuSuperior.php"); ?>
</div>

</div>
<div id="content">
<div id="left">
<div class="post">
<div class="post_h">

</div>

<div class="postcontent">
<blockquote><h2 align="center">ESTADISTICAS DEL PERSONAL</h2></blockquote>
<script language="JavaScript1.2"> 
function verifyInput(_selList,_textBox) {
  var SI = eval(_selList+".selectedIndex");
  var SV = eval(_selList+".options[SI].value");
  eval(_textBox+".value = SV");
  document.FormBuscador.Cedula.focus()
}
</script>

<center><b>Tipo de Personal: </b><select name="Cargo" id="Cargo" onChange="cargo(this.value)"><option></option>
												<option value=Docente>Docente</option>
												<option value=Obrero>Obrero</option>
												<option value=Administrativo>Administrativo</option></select></center><br>

<div id="general" style="display: inline;">
<fieldset>
<legend align=left><b><font size=2>PERSONAL EN GENERAL</font></b></legend>
	<img alt='Pie chart' src='graficos/ListadoTotal.png' width=100% style='border: 1px solid gray;'/>
</fieldset>


<div class="post">
<span></span></div>
</div>

<div id="docente" style="display: none;">
<fieldset>
<legend align=left><b><font size=2>DOCENTES</font></b></legend>
	<img alt='Pie chart' src='graficos/ListadoDocentes.png' width=100% style='border: 1px solid gray;'/>
</fieldset>

<div class="post">
<span></span></div>
</div>

<div id="obrero" style="display: none;">
<fieldset>
<legend align=left><b><font size=2>OBREROS</font></b></legend>
	<img alt='Pie chart' src='graficos/ListadoObreros.png' width=100% style='border: 1px solid gray;'/>
</fieldset>

<div class="post">
<span></span></div>
</div>

<div id="administrativo" style="display: none;">
<fieldset>
<legend align=left><b><font size=2>ADMINISTRATIVOS</font></b></legend>
	<img alt='Pie chart' src='graficos/ListadoAdministrativos.png' width=100% style='border: 1px solid gray;'/>
</fieldset>

<div class="post">
<span></span></div>
</div>

<div name=botonera align=center>
	<input class=button type=button value=Volver onClick="location='index.php'">
</div>
</form>

<div align=right><a title='Ayuda' href="Manuales/ManualUsuario_8.2.pdf" onclick="window.open(this.href,'Manual','params'); return false"><img src='images/help.png' width=8% height=15%></a></div>

</div>
<div class="post_b">
<span></span></div>
</div>


</div>

<div class="post">
<div class="post_h">

</div>


</div>

<?php include("Menu.php"); ?>

<div class="clear"></div>
</div>
<div id="pagebottom"></div>

<div id="footer">
<P>&reg; Derechos Reservados @ CopyRight. 2011-2012</P>
<p>Programadores: Quintero E, Isturiz C, Uribe C, De Freitas J.</p>
</div>
</div>
</body>
</html>
